package com.sdjzu.wangfuying.rxjava2study.model;

/**
 * Created by Administrator on 2017/12/19.
 * .
 */

import android.os.Parcel;
import android.os.Parcelable;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;

import java.io.Serializable;

public class DemoBean implements Serializable, Parcelable {

    @SerializedName("error_code")
    @Expose
    private Integer errorCode;
    @SerializedName("reason")
    @Expose
    private String reason;
    public final static Parcelable.Creator<DemoBean> CREATOR = new Creator<DemoBean>() {


        @SuppressWarnings({
                "unchecked"
        })
        public DemoBean createFromParcel(Parcel in) {
            return new DemoBean(in);
        }

        public DemoBean[] newArray(int size) {
            return (new DemoBean[size]);
        }

    };
    private final static long serialVersionUID = -1988243384540225957L;

    protected DemoBean(Parcel in) {
        this.errorCode = ((Integer) in.readValue((Integer.class.getClassLoader())));
        this.reason = ((String) in.readValue((String.class.getClassLoader())));
    }

    /**
     * No args constructor for use in serialization
     */
    public DemoBean() {
    }

    /**
     * @param reason
     * @param errorCode
     */
    public DemoBean(Integer errorCode, String reason) {
        super();
        this.errorCode = errorCode;
        this.reason = reason;
    }

    public Integer getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(Integer errorCode) {
        this.errorCode = errorCode;
    }

    public DemoBean withErrorCode(Integer errorCode) {
        this.errorCode = errorCode;
        return this;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public DemoBean withReason(String reason) {
        this.reason = reason;
        return this;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this).append("errorCode", errorCode).append("reason", reason).toString();
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder().append(reason).append(errorCode).toHashCode();
    }

    @Override
    public boolean equals(Object other) {
        if (other == this) {
            return true;
        }
        if ((other instanceof DemoBean) == false) {
            return false;
        }
        DemoBean rhs = ((DemoBean) other);
        return new EqualsBuilder().append(reason, rhs.reason).append(errorCode, rhs.errorCode).isEquals();
    }

    public void writeToParcel(Parcel dest, int flags) {
        dest.writeValue(errorCode);
        dest.writeValue(reason);
    }

    public int describeContents() {
        return 0;
    }

}